<?php

namespace lico\Tool;

class Encrypt
{

    protected $type = 'md5'; //md5,openssl,sha1

    protected $handler;

    public function __construct($type = '')
    {
        $type && $this->setType($type);
        $type = ucfirst(strtolower($this->type));
        $namespace = __CLASS__ . '\\' . $type;
        $this->handler = new $namespace;
    }

    /**
     * 设置加密方式
     */
    public function setType($type)
    {
        $this->type = $type;
        return $this->type;
    }

    /**
     * 获取加密类
     */
    public function getHandler()
    {
        return $this->handler;
    }
}
